package com.original.simuladoresws.controller;

import org.springframework.stereotype.Controller;

import com.original.simuladoresws.entities.TbSimulation;
import com.original.simuladoresws.entities.soap.SOAPBaseOutput;
import com.original.simuladoresws.entities.soap.SOAPObjectSaveInput;
import com.original.simuladoresws.service.SimulationService;
import com.original.simuladoresws.service.impl.SimulationServiceImpl;

@Controller
public class ObjectSaveController {
	SimulationService simulationService = new SimulationServiceImpl();
	public SOAPBaseOutput objectiveSave(SOAPObjectSaveInput input) {
		SOAPBaseOutput output = new SOAPBaseOutput();
		TbSimulation simu = new TbSimulation();
		simu.setId(simulationService.getId());
		simu.setNmUserName(input.getName());
		simu.setDsUserEmail(input.getEmail());
		simu.setDsUserDocument(input.getDocument());
		simu.setDsUserTelephone(input.getTelephone());
		simu.setDsUserTelephone2(input.getCelular());
		simu.setVlInitialAmount(input.getInitial_Amount());
		simu.setEsRetirement(input.getRetirement());
		simu.setDsObjective(input.getObjective());
		simu.setVlRequiredAmount(input.getRequired_Amount());
		simu.setVlMonthlyApplication(input.getMonthly_Application());
		simu.setVlInvestmentTime(input.getInvestment_Time());
		simu.setVlInvestmentTimeType(input.getInvestment_Time_Type());
		simu.setVlSuitabilityTax(input.getSuitability_Tax());
		simu.setVlCurrentAge(input.getCurrent_Age());
		simu.setVlRetirementStartAge(input.getRetirement_Start_Age());
		simu.setVlRetirementFinishAge(input.getRetirement_Finish_Age());
		try {
			simulationService.save(simu);
			output.setError(false);
			output.setMessage("");
		} catch (Exception e) {
			output.setError(false);
			output.setMessage("");
		}
		return output;
	}
}
